/*
 * @Author: WuFeng <763467339@qq.com>
 * @Date: 2024-07-10 14:56:20
 * @LastEditTime: 2024-07-10 14:56:20
 * @LastEditors: WuFeng <763467339@qq.com>
 * @Description: 
 * @FilePath: \chu-meng\client\src\utils\utils.js
 * @Copyright 版权声明
 */

/**
 * 生成UUID
 * @export
 * @return {*} 
 */
export function generateUUID(prefix = '') {
  var buf = new Uint32Array(4);
  window.crypto.getRandomValues(buf);
  var idx = -1;
  return prefix + 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
    idx++;
    var r = (buf[idx>>3] >> ((idx%8)*4)) & 15;
    r = r ^ (c == 'x' ? 0 : (c == 'y' ? 8 : 3));
    return r.toString(16);
  });
}